(function(){
    $(".header-right").on("touchstart",function(){
        $(".right-menu").fadeToggle()
    })

    var height1=$(".nav-floor").get(0).offsetTop;
    var height2=$(".nav-floor").height();
    var height3=$(".bag").get(0).offsetTop-height2-30;
    var height4=$(".bag").get(1).offsetTop-height2-30;
    var height5=$(".bag").get(2).offsetTop-height2-30;
    var height6=$(".bag").get(3).offsetTop-height2-30;
    var height7=$(".bag").get(4).offsetTop-height2-30;
    window.onload=function(){
        window.addEventListener('scroll', function () {
            var height=$("html").get(0).scrollTop
            // console.log($(".nav-floor").get(0).offsetTop)
        //    console.log($("html").get(0).scrollTop) 
            if(height>=height1){
                $(".nav-floor").css({"position":"fixed","top":0})
                $(".floors").css("margin-top",height2)
            }else{
                $(".nav-floor").css({"position":"relative"})
                $(".floors").css("margin-top",0)
            }
    
    
            if(height<height4){
                $(".nav-floor ul li").removeClass("active1").eq(0).addClass("active1")
            }else if(height>=height4&&height<height5){
                $(".nav-floor ul li").removeClass("active1").eq(1).addClass("active1")
            }else if(height>=height5&&height<height6){
                $(".nav-floor ul li").removeClass("active1").eq(2).addClass("active1")
            }else if(height>=height6&&height<height7){
                $(".nav-floor ul li").removeClass("active1").eq(3).addClass("active1")
            }else if(height>=height7){
                $(".nav-floor ul li").removeClass("active1").eq(4).addClass("active1")
            }
    
        })
        $(".nav-floor ul").on("touchstart","li",function(){
            $(".nav-floor ul li").removeClass("active1")
            $(this).addClass("active1")
            $("html").scrollTop($(".bag").get($(this).index()).offsetTop-height2)
        })


    }
   
   
}())